package com.wzs.workbench.service.impl;

import com.wzs.workbench.dao.CommentMapper;
import com.wzs.workbench.domain.Comment;
import com.wzs.workbench.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Resource
    private CommentMapper commentMapper;

    @Override
    public List<Comment> getCommentListByAid(String novelId) {
        return commentMapper.getCommentListByAid(novelId);
    }

    @Override
    public boolean saveComment(Comment comment) {
        boolean flag = true;

        int count = commentMapper.saveRemark(comment);

        if (count != 1) {
            flag = false;
        }

        return flag;
    }

    @Override
    public boolean deleteRemark(String id) {
        boolean flag = true;

        int count = commentMapper.deleteById(id);

        if (count != 1) {
            flag = false;
        }

        return flag;
    }

    @Override
    public boolean updateComment(Comment comment) {
        boolean flag = true;

        int count = commentMapper.updateComment(comment);

        if (count != 1) {
            flag = false;
        }

        return flag;
    }
}
